﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.TK
{
    class Class7
    {

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string a = ppa.PolicyActing.Policy.SelectedColRateFactors["领取年龄"].Trim();

            int receiveAge = 0;

            if (a == "50岁")
                receiveAge = 50;
            else if (a == "55岁")
                receiveAge = 55;
            else if (a == "60岁")
                receiveAge = 60;
            else if (a == "65岁")
                receiveAge = 65;
            else if (a == "70岁")
                receiveAge = 70;

            if (ppa.Age == receiveAge)
            {
                string c = ppa.PolicyActing.Policy.SelectedColRateFactors["给付比例"].Trim();

                double x = double.Parse(c);

                da.Value = ppa.Amount * x;
            }

        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {

            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                string a = ppa.PolicyActing.Policy.SelectedColRateFactors["领取年龄"].Trim();

                int receiveAge = 0;

                if (a == "50岁")
                    receiveAge = 50;
                else if (a == "55岁")
                    receiveAge = 55;
                else if (a == "60岁")
                    receiveAge = 60;
                else if (a == "65岁")
                    receiveAge = 65;
                else if (a == "70岁")
                    receiveAge = 70;


                if (ppa.Period == 0)
                {
                    da.Value = ppa.TotalFee;
                }
                else if (ppa.Period > 0)
                {
                    if (ppa.Age < receiveAge)
                    {
                        da.Value = ppa.Amount > ppa.TotalFee ? ppa.Amount : ppa.TotalFee;
                    }
                    else
                    {
                        double x = ppa.GetDutyTotalValue("生存保险金");

                        da.Value = ppa.Amount - x > ppa.TotalFee - x ? ppa.Amount - x : ppa.TotalFee - x;
                    }
                }

                ppa.IsCurrentFinish = true;
            }
        }

    }
}
